/**
 * 上传组件
 */
(function(){
    let uploadEle = document.querySelector('.y-upload');
    let uploadFile = uploadEle.firstElementChild;
    let imgEle = uploadFile.nextElementSibling.firstElementChild;
    let labelEle = imgEle.nextElementSibling;
    //文件转变事件
    uploadFile.onchange = function (event) {
        let file = event.target.files[0]; //获取选中文件
        let fileReader = new FileReader(); //实例化读文件对象
        fileReader.readAsDataURL(file); //读文件
        //文件读取完成
        fileReader.onload = function (e) {
            imgEle.src = e.target.result; //显示预览图片
            labelEle.style.opacity = '0';
        }
    }
})()